from datetime import datetime
from sqlalchemy import Column, DateTime, String, Integer

from src.db import TableBase
from src.enum.task import CrawlerStatusEnum

class CrawlerTask(TableBase):
    __tablename__ = "crawler_task"

    crawler_id = Column(String(32),primary_key=True)
    crawler_type = Column(Integer,index=True)
    crawler_params = Column(String(500),default=None)
    crawler_status = Column(Integer, index=True, default=CrawlerStatusEnum.INIT.value)
    crawler_times = Column(Integer,default=0)
    reason = Column(String(500),default=None)
    exec_time = Column(DateTime, default=None)
    exec_result = Column(Integer, default=None)
    data_file_path = Column(String(500),default=None)
    create_time = Column(DateTime,default=datetime.now())
